package com.eight.course.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eight.common.pojo.EduCourse;
import com.eight.common.vo.Result;
import com.eight.course.service.CheckCourseService;
import com.eight.course.service.CourseService;
import com.eight.course.vo.CourseVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @program: qy8-education
 * @description:
 * @author: 张亚祥
 * @create: 2023-05-26 11:27
 **/
@RestController
@RequestMapping("core/course")
@ApiModel(value = "课程分类")
public class CourseController {
    @Resource
    private CourseService courseService;

    @Resource
    private CheckCourseService checkCourseService;

    @PostMapping("/findCourse/{currentSize}/{pageSize}")
    @ApiOperation(value = "课程分类分页条件查询")
    public Result findCourse(@PathVariable Integer currentSize, @PathVariable Integer pageSize,@RequestBody CourseVo courseVo){
        Page<EduCourse> page = courseService.findPage(currentSize, pageSize,courseVo);
        return Result.success(page);
    }

    @PostMapping("/changeStatus/{id}/{status}")
    @ApiOperation(value = "修改课程分类状态")
    public Result changeStatus(@PathVariable String id,@PathVariable String status){
        System.out.println(id);
        int status1 = courseService.updateStatus(id, status);
        return Result.success();
    }

    @PostMapping("/updateCourse")
    @ApiOperation(value = "修改课程分类")
    public Result updateCourse(@RequestBody EduCourse eduCourse){
        int i = courseService.updateCourse(eduCourse);
        return Result.success();
    }

    @PostMapping("/findCourseCheck/{currentSize}/{pageSize}")
    @ApiOperation(value = "课程管理分页条件查询")
    public Result findCourseCheck(@PathVariable Integer currentSize, @PathVariable Integer pageSize,@RequestBody CourseVo courseVo){
        Page<EduCourse> page = checkCourseService.findCherckCourse(currentSize, pageSize,courseVo);

        return Result.success(page);
    }
    @PostMapping("/updateCourseDescription")
    @ApiOperation(value = "修改课程分类")
    public Result updateCourseDescription(@RequestBody EduCourse EduCourse){
        System.out.println(EduCourse.getDescription());
        System.out.println(EduCourse.getTitle());
        int i = courseService.updateCourseDescription(EduCourse);
        return Result.success();
    }
}
